package tcpdemo.tcptest2;

import java.io.*;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        // 客户端
        Socket socket = new Socket("127.0.0.1",10000);
        // 获取本地文件
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("UdpDemo\\ClientDir\\1.jpg"));
        // 写到服务器中
        OutputStream os = socket.getOutputStream();
        BufferedOutputStream bos = new BufferedOutputStream(os);

        int b;
        while ((b = bis.read())!= -1){
            bos.write(b);
        }
        socket.shutdownOutput();

        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String line;
        while ((line = br.readLine())!= null){
            System.out.println(line);
        }

        socket.close();
        bis.close();
        br.close();


    }
}
